<template>
  <div>
    <h1>审批</h1>
    <table>
      <tr>
        <td>姓名</td>
        <td>请假类型</td>
        <td>请假时间</td>
        <td>操作</td>
      </tr>
      <tr v-for="i in list" :key="i.id">
        <td>{{ i.uname }}</td>
        <td v-if="i.jia==1">病假</td>
        <td v-else>事假</td>
        <td>{{ i.ctime }}</td>
        <td>
          <van-button @click="dian(i.id,i.jia,1)">同意</van-button>
          <van-button @click="dian(i.id,i.jia,2)">不同意</van-button>
        </td>
      </tr>
    </table>
  </div>
</template>

<script>
import axios from 'axios'

export default {
  name: "shenpi",
  data() {
    return {
      list: []
    }
  },
  methods: {
    get_shenpi() {
      axios.get('http://localhost:5000/qingjia')
          .then(res => {
            this.list = res.data.list
          })
    },
    dian(id, jia, type) {
      axios.post('http://localhost:5000/shenpi', {id: id, jia: jia, type: type})
          .then(res => {
            if (res.data.code == 200) {
              alert('操作成功')
              this.get_shenpi()
            }
          })

    }
  },
  mounted() {
    this.get_shenpi()
  }
}
</script>

<style scoped>

</style>